// Capitalist City - Business Simulation Game
// Copyright (C) 2011 Azlan Mukhtar
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include <QApplication>
#include "language.h"
#include "gamesettings.h"
#include "game.h"

QTranslator g_Translator;

CLanguage::CLanguage()
{
}

void CLanguage::Init()
{
    QString sLocalePath;
    QFile fLocale;

    // Construct path for locale file
    if (g_Setting->m_Locale == k_eLocale_enUS)
        sLocalePath = g_Setting->ResourcePath + "lang/en-US.txt";
    else if (g_Setting->m_Locale == k_eLocale_myMY)
        sLocalePath = g_Setting->ResourcePath + "lang/my_MY.txt";

    // Open locale file
    g_Translator.load(sLocalePath);
    g_qApp->installTranslator(&g_Translator);
}

QString CLanguage::_(const char* context, const char* text)
{
    return QApplication::translate(context, text, 0, QApplication::UnicodeUTF8);
}
